package com.dwjm.shop.utils;

import java.sql.Connection;
import java.sql.DriverManager;

public class ConnectionDatabaseForMySQLUseJdbc {
    private static final String DRIVER = "com.mysql.cj.jdbc.Driver";
    private static final String URL = "jdbc:mysql://localhost:3306/shopping?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
    private static final String USER = "root";
    private static final String PASSWORD = "root";

    static Connection connection = null;

    public static Connection getConnection(){
        try {
            Class.forName(DRIVER);
            connection = DriverManager.getConnection(URL,USER,PASSWORD);
            return connection;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
